In [ ]:
1+10
x=10
# import math
# math.log(x)+math.exp(x)+math.tan(x)
# import math as m
# m.log(x)+m.exp(x)+m.tan(x)+m.pi
# from math import sin, cos,pi
# sin(x)+cos(x)+pi
from math import *
globals()
In [ ]:
cos(pi/3)
tan(pi/3)
z=1+1j
# import cmath
from cmath import exp
# from cmath import *
exp(z)
Exercice¶
1 fonctions suivantes:
surface:(R,x)=>retoune s qui est la surface de la portion definie par langle x et le rayon
arc: (R,x)=> retoune s qui est la longueur de l arc definie par langle x et le rayon
2- modifier les fonction ci dessus pour aue en cas d absence du parametre x, prenez 2*pi comme valeur par defaut
In [ ]:
from math import sin,pi
def surface(R,x):
a=10
b=20
c=a+b
# from math import sin,pi
s=R**2*(x-sin(x))/2
# return 'salut'
return s
surface(25,1)
surface(25,pi/3)+surface(25,pi/3)+surface(25,pi/3)+a
surface(25)
In [13]:
def arc(R,x):
y=x%(2*pi)
print(y)
return R*y
arc(10,9*pi/2)
1.5707963267948966
Out[13]:
15.707963267948966
In [26]:
def surface(R,x=2*pi):
s=R**2*(x-sin(x))/2
# return 'salut'
return s
def arc(R,x=2*pi):
y=x%(2*pi)
if(y==0):
y=2*pi
# print(y)
return R*y
arc(10)
6.283185307179586
Out[26]:
62.83185307179586
Exercice¶
fonction: saisie aui permet de lire une reel positif et retourne la mesur principale de la valeur saisie modulo 2*pi
In [4]:
from math import pi
def saisie():
while True:
x=float(input('svp donner un reel positif'))
if x>=0:break
print('i7chemm a3tina un reel positif')
return x%(2*pi)
saisie()
Out[4]:
4.7522203923062065
Exercice¶
fonctrion principal nommee main qui:
- accept le type comme parametree:
- permet de saisir le rayon d un cercle
- permet de saisir l angle d un cercle: ( si x est absent la valeur par defaut sera 2*pi )
retourn la valeur du type selon le parametre type
In [ ]:
def main(type):
r=float(input('donner le rayon'))
x=saisie()
if type=='arc':
return arc(r,x)
elif type=='surface':
return surface(r,x)
else:
return 'type non conforme'
In [7]:
def f(x,y):
return (x+1,y+1)
f(10,20)
Out[7]:
(11, 21)
In [9]:
3,4,5
Out[9]:
(3, 4, 5)